package designpattern.proxy.impl;

import designpattern.proxy.Buyer;
import org.apache.log4j.Logger;

/**
 * @author 吴阳基
 * @datetime 2024/1/6 9:29
 */
public class IntermediaryImpl implements Buyer {
    private Logger logger = Logger.getLogger(IntermediaryImpl.class);
    private Buyer target;

    /**
     * 构造函数，传入目标对象，实现代理功能。
     * @param target
     */
    public IntermediaryImpl(Buyer target) {
        this.target = target;
    }

    /**
     * 中介方法，实现代理功能。
     * @return
     */
    @Override
    public String havealook() {
        before();
        String feedback = target.havealook();
        after();
        return "看房记录：买家反馈" + feedback;

    }
    private void before(){
        logger.info("买家进入看房记录");
    }
    private void after(){
        logger.info("买家离开看房记录");
    }
}
